package ahl;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
 * These tests will test the <code>getClosestAngle()</code> method calculates
 * the closest angle to turn the gun right correctly.
 * 
 * (e.g. If gun has to turn 359 degrees to the right, it's better to turn -1
 * degrees to the right since it's closer).
 * @author Arthur Lee
 */
public class TestRelativeAngleMethod {
  
  /**
   * Bunch of junit tests testing <code>getClosestAngle()</code> method.
   */
  @Test
  public void testRelativeAngles() {
    BattleFire robot = new BattleFire();
    //Testing angles between and including -180 to 180.
    double turnAngle = robot.getClosestAngle(180);
    assertEquals("Test #1 for getting the relative angle", turnAngle, 180, 0.1);
    turnAngle = robot.getClosestAngle(-180);
    assertEquals("Test #2 for getting the relative angle", turnAngle, -180, 0.1);
    turnAngle = robot.getClosestAngle(0);
    assertEquals("Test #3 for getting the relative angle", turnAngle, 0, 0.1);
    //Testing angles between greater than 180 or less than -180.
    turnAngle = robot.getClosestAngle(274);
    assertEquals("Test #4 for getting the relative angle", turnAngle, -86, 0.1);
    turnAngle = robot.getClosestAngle(-209);
    assertEquals("Test #5 for getting the relative angle", turnAngle, 151, 0.1);
  }

}
